from decimal import Decimal

from src.enums.enums import Operation, Direction


class Instruction:

    def __init__(self,
                 operation: Operation,
                 direction: Direction,
                 price: Decimal,
                 quantity: Decimal,
                 reason: str = ''
                 ):
        self.operation = operation
        self.direction = direction
        self.price = price
        self.quantity = quantity
        self.reason = reason

    def is_open(self) -> bool:
        if self.operation == Operation.BUY and self.direction == Direction.LONG:
            return True
        if self.operation == Operation.SELL and self.direction == Direction.SHORT:
            return True
        return False
